package com.probox.customer.api.domain;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.probox.common.core.annotation.Excel;
import com.probox.common.core.utils.StringUtils;
import com.probox.common.core.utils.money.MoneyUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 客户等级对象 customer_level
 *
 * @author zsy
 * @date 2021-05-27
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@TableName("customer_level")
@ApiModel(description = "客户等级")
public class CustomerLevel implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 会员级别ID
     */
    //默认主键自增
    @ApiModelProperty(value = "会员级别ID")
    @TableId(value = "LEVEL_ID", type = IdType.AUTO)
    private Long levelId;
    /**
     * 平台ID
     */
    @ApiModelProperty(value = "平台ID")
    @Excel(name = "平台ID")
    private Long platformId;
    /**
     * 客户等级
     */
    @ApiModelProperty(value = "客户等级", required = true)
    @Excel(name = "客户等级")
    private Integer customerGrade;
    /**
     * 客户模式
     */
    @ApiModelProperty(value = "客户模式", required = true)
    @Excel(name = "客户模式")
    private String customerPattern;
    /**
     * 级别名称
     */
    @ApiModelProperty(value = "级别名称", required = true)
    @Excel(name = "级别名称")
    private String levelName;

    /**
     * 级别图标
     */
    @ApiModelProperty(value = "级别图标", required = true)
    @Excel(name = "级别图标")
    private String levelIcon;


    private String levelIconItalic;

    private String levelIconNo;

    private String levelBanner;

    /**
     * 卡面
     */
    @ApiModelProperty(value = "卡面", required = true)
    @Excel(name = "卡面")
    private String caedFace;
    /**
     * 级别背景色
     */
    @ApiModelProperty(value = "级别背景色")
    @Excel(name = "级别背景色")
    private String levelColor;
    /**
     * 级别图标
     */
    @ApiModelProperty(value = "级别图标")
    @Excel(name = "级别图标")
    private String levelImage;
    /**
     * 最小积分
     */
    @ApiModelProperty(value = "最小积分")
    @Excel(name = "最小积分")
    private Integer minScore;
    /**
     * 粉丝数量
     */
    @ApiModelProperty(value = "粉丝数量")
    @Excel(name = "粉丝数量")
    private Integer fansNumber;
    /**
     * 业绩
     */
    @ApiModelProperty(value = "业绩")
    @Excel(name = "业绩")
    private BigDecimal performance;
    /**
     * 客户数量
     */
    @ApiModelProperty(value = "客户数量")
    @Excel(name = "客户数量")
    private Long customerNumber;
    /**
     * 付费规则ID
     */
    @ApiModelProperty(value = "付费规则ID")
    @Excel(name = "付费规则ID")
    private String ruleId;
    /**
     * 状态
     */
    @ApiModelProperty(value = "状态")
    @Excel(name = "状态")
    private String dataStatus;
    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**
     * 修改时间
     */
    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人")
    @Excel(name = "创建人")
    private Long createUser;
    /**
     * 修改人
     */
    @ApiModelProperty(value = "修改人")
    @Excel(name = "修改人")
    private Long updateUser;
//    /**
//     * 客户权益ID
//     */
//    @ApiModelProperty(value = "客户权益ID")
//    @Excel(name = "客户权益ID")
//    private Long gradeprivilegeId;
    /**
     * 启动状态
     */
    @ApiModelProperty(value = "启动状态")
    @Excel(name = "启动状态")
    private String startStatus;
    /**
     * 直接分拥比例
     */
    @ApiModelProperty(value = "直接分拥比例")
    @Excel(name = "直接分拥比例")
    private BigDecimal directPointsPoints;
    /**
     * 间接分拥比例
     */
    @ApiModelProperty(value = "间接分拥比例")
    @Excel(name = "间接分拥比例")
    private BigDecimal indirectPointsPoints;
    /**
     * 自购分拥比例
     */
    @ApiModelProperty(value = "自购分拥比例")
    @Excel(name = "自购分拥比例")
    private BigDecimal selfbuyPointsPoints;

    /**
     * 创建人名称
     */
    @ApiModelProperty(value = "创建人名称")
    @Excel(name = "创建人名称")
    private String createName;

    /**
     * 创建人名称
     */
    @ApiModelProperty(value = "修改人名称")
    @Excel(name = "修改人名称")
    private String updateName;


    public BigDecimal getDirectPointsPointsStr() {
        if (directPointsPoints != null) {
            BigDecimal Hundred = new BigDecimal("100");
            return directPointsPoints.multiply(Hundred);
        }
        return null;
    }

    public BigDecimal getIndirectPointsPointsStr() {
        if (indirectPointsPoints != null) {
            BigDecimal Hundred = new BigDecimal("100");
            return indirectPointsPoints.multiply(Hundred);
        }
        return null;
    }

    public BigDecimal getSelfbuyPointsPointsStr() {
        if (selfbuyPointsPoints != null) {
            BigDecimal Hundred = new BigDecimal("100");
            return selfbuyPointsPoints.multiply(Hundred);
        }
        return null;
    }

    public BigDecimal getPerformanceStr() {
        if (performance == null) return null;
        return MoneyUtils.changeF2B2(performance);
    }


    /**
     * 折扣的值
     */
    @TableField(exist = false)
    private String levelValue;


    public String getLevelNameStr(){
        if(StringUtils.isEmpty(levelValue)){
            return levelName;
        }
        return levelName+"("+levelValue+"折)";
    }

}
